const addBtn = document.querySelector('#btn-add'),
      inputName = document.querySelector('#inputName'),
      inputPrice = document.querySelector('#inputPrice'),
      inputNum = document.querySelector('#inputNum'),
      msgWrap = document.querySelector('#msgWrap')


      utils.on(addBtn, 'click',function() {
        const name = inputName.value,
              price = inputPrice.value,
              num = inputNum.value
        
        utils.fetch('./api/shop/add.php' , {name, price, num}).then( resp =>{
            console.log(resp)
            msgWrap.innerHTML = resp.list.msg
            if(resp.code === 200) {
                msgWrap.classList.add('text-success')
                setTimeout(() => {
                    $('#addModal').modal('hide')
                    getLIst()
                }, 2000);
            }else{
                msgWrap.classList.add('text-danger')
            }
            setTimeout(() => {
                msgWrap.innerHTML = '' 
                msgWrap.className = 'text-center'
            }, 2000)
        })
    })
    $('#addModal').on('hidden.bs.modal', function (e) {
        // 模态框隐藏的时候触发的事件
        inputNum.value = inputPrice.value = inputName.value = ''
      })
    
    